import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import Home from '../components/Home.vue'
import Welcome from '../components/Welcome.vue'

import ReservationSpace from '../components/spacemanagement/reservationSpace'
import spatialClassification from '../components/spacemanagement/spatialClassification'
import appointmentApproval from '../components/appointmentManagement/appointmentApproval'
import useRecord from '../components/appointmentManagement/useRecord'
import studentInformation from '../components/appointmentManagement/studentInformation'
import useEvaluation from '../components/appointmentManagement/useEvaluation'

import space from '../components/dataStatistics/space'
import bespeak from '../components/dataStatistics/bespeak'
import use from '../components/dataStatistics/use'


import user from '../components/systemGuanli/user'
import role from '../components/systemGuanli/role'
import menu from '../components/systemGuanli/menu'
import systemParameter from '../components/systemGuanli/systemParameter'
import noticeAffiche from '../components/systemGuanli/noticeAffiche'
import complaintAdvice from '../components/systemGuanli/complaintAdvice'
// import { component } from 'vue/types/umd'

Vue.use(VueRouter)

// const routes = [
//     {
//         path: '/login',
//         name: 'Login',
//         redirect: '',
//         component: Login
//     }
// ]

// 根据用户的权限不同，所能看到的页面和可操作性也不同
// 超级管理员：所有页面都可以看得到
// 普通管理员：普通管理员的权限

// addRouter()

// 准备动态加载的路由
// export const DynamicRoutes = [
//     {
//         path: "",
//         component: Home,
//         name: 'container',
//         redirect: '/welcome',
//         meta: {
//             // 有一些页面是否需要登录之后才能看得到
//             requiresAuth: true,
//             name: '首页'
//         },
//         children: [
//             {

//             }
//         ]
//     }
// ]




const routes = [
    //路由导航重定向到登录页面
    { path: '/', redirect: '/login' },

    { path: '/login', component: Login },
    {
        path: '/home',
        component: Home,
        redirect: '/welcome',
        children: [
            // 空间管理
            { path: '/reservationSpace', component: ReservationSpace },
            { path: '/spatialClassification', component: spatialClassification },

            // 预约管理
            { path: '/appointmentApproval', component: appointmentApproval },
            { path: '/useRecord', component: useRecord },
            { path: '/studentInformation', component: studentInformation },
            { path: '/useEvaluation', component: useEvaluation },

            // 数据统计
            { path: '/space', component: space },
            { path: '/bespeak', component: bespeak },
            { path: '/use', component: use },

            // 系统管理
            { path: '/user', component: user },
            { path: '/role', component: role },
            { path: '/menu', component: menu },
            { path: '/systemParameter', component: systemParameter },
            { path: '/noticeAffiche', component: noticeAffiche },
            { path: '/complaintAdvice', component: complaintAdvice },

            { path: '/welcome', component: Welcome },
        ]
    }
]



const router = new VueRouter({
    routes
})
//挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//     //to将要访问的路径
//     //from从哪个路劲来
//     //next 是一个函数， 表示放行
//     // next() 放行 next('/login') 要强制跳转到的路劲
//     if (to.path == '/login') return next()
//         //获取token
//     const tokenStr = window.sessionStorage.getItem('token')
//     if (!tokenStr) return next('/login')
//     next()
// })

export default router